#include <iostream>
#include <vector>

using namespace std;

int T;
vector<vector<int>> a;

int main()
{
	cin >> T;
	while(T--)
	{
		int n, m, k; cin >> n >> m >> k;
		int cnt = 1;
		for(int j = 1; j <= n; j++)
		{
			for(int i = 1; i <= m; i++)
			{
				a[i].push_back(cnt++);
				if(cnt > k) cnt = 1;
			}
		}
		for(int i = 1; i <= n; i++)
		{
			for(int j = 1; j <= m; j++)
			{
				cout << a[i][j] << " ";
			}
			cout << endl;
		}
	}
	
	return 0;
}
